<?php

namespace Nimo\Bundle\BookstoreApiBundle\Entity\Book;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
 * Nimo\Bundle\BookstoreApiBundle\Entity\Book\Category
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Nimo\Bundle\BookstoreApiBundle\Entity\Book\CategoryRepository")
 */
class Category
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $name
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

    /**
     * @var integer $bookCount
     *
     * @ORM\Column(name="book_count", type="integer")
     */
    private $bookCount = 0;

    /**
     * @var ArrayCollection $books
     *
     * @ORM\OneToMany(targetEntity="Book", mappedBy="category")
     */
    protected $books;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->books = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Category
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set bookCount
     *
     * @param integer $bookCount
     * @return Category
     */
    public function setBookCount($bookCount)
    {
        $this->bookCount = $bookCount;
    
        return $this;
    }

    /**
     * Get bookCount
     *
     * @return integer 
     */
    public function getBookCount()
    {
        return $this->bookCount;
    }

    /**
     * Add books
     *
     * @param Book $books
     * @return Category
     */
    public function addBook(Book $books)
    {
        $this->books[] = $books;
    
        return $this;
    }

    /**
     * Remove books
     *
     * @param Book $books
     */
    public function removeBook(Book $books)
    {
        $this->books->removeElement($books);
    }

    /**
     * Get books
     *
     * @return Collection
     */
    public function getBooks()
    {
        return $this->books;
    }
}